<template>
  <div id="main1" style="width:100%;height:400px">
  </div>
</template>




<script>
import * as echarts from 'echarts' //引入
import { stat1} from "@/api/stat.js";
export default {
  data() {
    return {}
  },

  mounted() {
        stat1().then(res=>{
        var datArr=[];
        var orderCuntArr=[];
        console.log(res)
        res.forEach(itme => {
          datArr.push(itme.dat)
          orderCuntArr.push(itme.count1)  
        });

        


         // 基于准备好的dom，初始化echarts实例
    var myChart4 = echarts.init(document.getElementById('main1'))
    // 绘制图表
    var option4 = {
      title: {
        left: 'center',
        text: '每月订单金额统计',
      },
      tooltip: {},
      xAxis: {
        data: datArr,
      },
      yAxis: {
        minInterval: 1
      },
      series: [
        {
          name: '订单金额',
          type: 'bar',
          data:orderCuntArr,
        },
      ],
    }

    myChart4.setOption(option4)

       })

   
  },
  
  
}
</script>